package code;

import java.util.Scanner;

public class WordNum_day10_shenxinfu {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String word_str = sc.nextLine();
        String[] words = word_str.split(",");
        int match=0;
        for (int i = 0; i <words.length; i++) {
            if(IsSunWord(str,words[i])){
                match++;
            }
        }
        System.out.println(match);
    }
    public static boolean IsSunWord(String str,String word){
        int i=0,j=0;
        while(i<str.length()&&j<word.length()){
            if(str.charAt(i)==word.charAt(j)){
                j++;
            }
            i++;
        }
        return j == word.length();
    }
}
